//
//  KLCarouselCell.m
//  Lunbo
//
//  Created by juwangkeji on 2018/7/10.
//  Copyright © 2018年 juwangkeji. All rights reserved.
//

#import "KLCarouselCell.h"
#import "KLconst.h"
#import <UIImageView+WebCache.h>
@interface KLCarouselCell()
@property(nonatomic,weak) UIImageView * m_ImageView;
@end

@implementation KLCarouselCell
//-(UIImageView *)m_ImageView{
//    if (!_m_ImageView) {
//        _m_ImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, __KLVIEWWIDTH__-20, __KLVIEWHEIGHT__-20)];
//         NSLog(@"imageName---%@",self.imageName);
//    }
//    return _m_ImageView;
//}


-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
       UIImageView *  m_ImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, __KLVIEWWIDTH__-20, __KLVIEWHEIGHT__-20)];
        self.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:m_ImageView];
        self.m_ImageView = m_ImageView;
    }
    return self;
}


-(void)setImageName:(NSString *)imageName{
    _imageName = imageName;
//    NSURL * url = [NSURL URLWithString:imageName];
//    [self.m_ImageView sd_setImageWithURL:url];
    self.m_ImageView.image = [UIImage imageNamed:imageName];
}

-(void)drawRect:(CGRect)rect{
    UIBezierPath * maskPath = [UIBezierPath bezierPathWithRoundedRect:_m_ImageView.bounds cornerRadius:20];
    CAShapeLayer * maskLayer =[[CAShapeLayer alloc] init];
    maskLayer.frame =self.m_ImageView.bounds;
    maskLayer.path = maskPath.CGPath;
    self.m_ImageView.layer.mask = maskLayer;
}
@end
